﻿@{
    ViewBag.Title = "MenuList";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}
@section HeadScript {
    @*    <script src="@Url.Content("~/Scripts/business/admin/MenuList.js")" type="text/javascript"></script>*@
    <script type="text/javascript">
        $(function () {
            autoResize({ dataGrid: '#MenuGrid', gridType: 'treegrid', callback: mygrid.bindGrid, height: 5 });
            $('#btnAdd').click(MenuMethod.Add);
        });

        var navgrid;
        var mygrid = {
            bindGrid: function (size) {
                navgrid = $('#MenuGrid').treegrid({
                    toolbar: '#toolbar',
                    iconCls: 'icon icon-org',
                    width: size.width,
                    height: size.height,
                    nowrap: true,
                    rownumbers: true,
                    animate: true,
                    resizable: true,
                    collapsible: false,
                    url: '@Url.Action("GetMenuListData")',
                    idField: 'ID',
                    treeField: 'MenuName',
                    frozenColumns: [[
                        { title: '菜单名称', field: 'MenuName', width: 200 }
                    ]],
                    columns: [[
                        { title: '简称', field: 'MenuDesc', width: 120, align: 'center' },
                        { title: '链接地址', field: 'NavigateUrl', width: 150, align: 'center' },
                        { title: '图标样式', field: 'IconCss', width: 100, align: 'center' },
                        { title: '排序', field: 'SeqNum', width: 100, align: 'center' },
                        { title: '有效', field: 'IsEnable', width: 100, align: 'center', formatter: imgcheckbox },
                        { title: '菜单类型', field: 'MenuCategory', width: 80, align: 'center' },
                        { title: 'ID', field: 'ID', hidden: true }
                    ]]
                });
            },
            reload: function () {
                navgrid.treegrid('reload');
            },
            selected: function () {
                return navgrid.treegrid('getSelected');
            }
        }

        var imgcheckbox = function (cellvalue, options, rowObject) {
            return cellvalue ? '<img src="/css/icon/ok.png" alt="正常" title="正常" />' : '<img src="/css/icon/stop.png" alt="禁用" title="禁用" />';
        }

        var MenuMethod = {
            Add: function () {
                art.dialog.open("@Url.Action("MenuAdd")", {
                    id: "MenuAdd",
                    title: "添加菜单",
                    lock: true,
                    opacity: 0.5,
                    resize: false,
                    drag: false,
                    close: function () {
                        navgrid.treegrid('reload');
                    }
                });
            }
        }

    </script>
}

<div style="padding: 2px; margin: 0px;">
    <div class="toolbar">
        <a id="a_refresh" class="easyui-linkbutton" style="float: left" plain="true" href="javascript:;" icon="icon-reload" title="重新加载">刷新</a>
        <div class='datagrid-btn-separator'></div>
        <a id="btnAdd" class="easyui-linkbutton" style="float: left" plain="true" href="javascript:;" icon="icon-user_add" title="添加">添加</a><a id="a_edit" class="easyui-linkbutton" style="float: left" plain="true" href="javascript:;" icon="icon-user_edit" title="修改">修改</a><a id="a_delete" class="easyui-linkbutton" style="float: left" plain="true" href="javascript:;" icon="icon-user_delete" title="删除">删除</a><div class='datagrid-btn-separator'></div>
        <div class='datagrid-btn-separator'></div>
        <a id="a_export" class="easyui-linkbutton" style="float: left" plain="true" href="javascript:;" icon="icon-user_go" disabled="True" title="导出数据">导出</a>
    </div>
    <table id="MenuGrid"></table>
</div>
